// 函数类型中, 可选参数必须位于必选参数之后
// 函数类型中, 可选参数与默认值不能一起用
function add(x: number = 100, y?: number): number {
    return y ? x + y : x;
}
// 函数类型中, 无函数返回值写 undefined 更好
function functionReturn(): void { return; }
function functionReturn2(): undefined { return; }
// 函数类型抽离
type FunctionType = (name: string, age: number) => string
const functionType: FunctionType= (name, age) => {
    return `${name} ${age}`
}


// 类
class Animate {
    // 实例化之后才可以访问
    private name: string;
    private age: number;

    // 无需实例化也可以访问
    static sex = 'male'

    constructor(personName: string, personAge: number) {
        this.name = personName;
        this.age = personAge;
    }

    public getDesc(): string {
        return `${this.name} at ${this.age} years old`;
    }

    public getName(): string {
        return this.name;
    }

    public getUpperCaseName(): string {
        return this.name.toLocaleUpperCase();
    }
}
const animate = new Animate('Linbudu', 18);
console.log(Animate.sex);
console.log(animate.getDesc());
console.log(animate.getName());